package com.xh.petdogexpert.expert.controller;

import java.util.List;

import javax.servlet.http.HttpSession;

import org.apache.ibatis.annotations.Param;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.xh.petdogexpert.base.BaseController;
import com.xh.petdogexpert.base.BaseException;
import com.xh.petdogexpert.base.ResponseData;
import com.xh.petdogexpert.expert.dto.Disease;
import com.xh.petdogexpert.expert.dto.Symptom;
import com.xh.petdogexpert.expert.service.IDiseaseService;
import com.xh.petdogexpert.user.controller.UserController;
import com.xh.petdogexpert.user.dto.User;

@RequestMapping(value = "/expert")
@Controller
public class DiseaseController extends BaseController {

	@Autowired
	IDiseaseService diseaseService;

	@Autowired
	HttpSession session;
	final static Logger logger = LoggerFactory.getLogger(DiseaseController.class);

	@RequestMapping(value = "/queryDisease")
	@ResponseBody
	public ResponseData queryDisease(Disease disease) {
		
		ResponseData rData = new ResponseData();
		List<Disease> diseases = diseaseService.queryDisease(disease);
		System.out.println("!!!!"+diseases);
		rData.setData(diseases);
		return rData;
	}
	@RequestMapping(value = "/getDisease")
	@ResponseBody
	public ResponseData getDisease(Disease disease) throws BaseException {

		ResponseData rData = new ResponseData();
		Disease rDisease = null;

		rDisease = diseaseService.getDisease(disease);
		rData.setData(rDisease);

		return rData;
	}
	@RequestMapping(value = "/addUpdateDisease")
	@ResponseBody
	public ResponseData addUpdateDisease(Disease disease) throws BaseException {

		ResponseData rData = new ResponseData();

		
		int id = diseaseService.addUpdateDisease(disease);
		if (disease.getId() != null) {
			rData.setMsg("修改症状成功");
		} else {
			rData.setMsg("新增症状成功");
		}
		rData.data = id;

		return rData;
	}
	@RequestMapping(value = "/deleteDisease")
	@ResponseBody
	public ResponseData deleteDisease(Disease disease) throws BaseException {

		ResponseData rData = new ResponseData();

		int count = diseaseService.deleteDisease(disease);
		rData.setData(count);

		return rData;
	}

//	@RequestMapping(value="symptom/getLastSymptoms")
//	@ResponseBody
//	public List<Symptom> getLastSymptoms(@RequestParam(defaultValue = "1")Integer page, @RequestParam(defaultValue = "10") Integer pageSize) {
//		return symptomService.getLastSymptoms(page, pageSize);
//	}
}
